package com.rillflow.v2c;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;

public class WidgetProvider extends AppWidgetProvider{
	
	public void onReceive(Context context, Intent intent) {
		//Log.d("v2c","onReceive : action="+intent.getAction());
		super.onReceive(context, intent);
	}
	
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
	{
		RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
		views.setImageViewResource(R.id.wedgetImage, R.raw.widget);

		Intent intent = new Intent(context, VoiceInput.class);
		intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds);
		
		// Intent action
		intent.setAction("com.rillflow.v2c");
		
		// OnClick Event
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
		views.setOnClickPendingIntent(R.id.wedgetImage, pendingIntent);
		
		appWidgetManager.updateAppWidget(appWidgetIds, views);
	}
}
